package com.tanhua.db.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanhua.api.SoulAppraiseApi;
import com.tanhua.db.mapper.SoulAppraiseMapper;
import com.tanhua.model.soul.SoulAppraise;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class SoulAppraiseApiImpl implements SoulAppraiseApi {

    @Autowired
    private SoulAppraiseMapper soulAppraiseMapper;

    @Override
    public SoulAppraise getLevel(Integer recordScore) {
        LambdaQueryWrapper<SoulAppraise> qw = new LambdaQueryWrapper();
        int score = recordScore.intValue();
        int level = 0;
        if(score>=10&&score <20){
            level=1;
        }else if (score >= 21 && score <= 40){
            level=2;
        }else if (score >= 41 && score <= 60) {
            level=3;
        }else {
            level=4;
        }
        qw.eq(SoulAppraise::getId,level);
        SoulAppraise soulAppraise = soulAppraiseMapper.selectOne(qw);
        return soulAppraise;
    }
}
